package cn.dnui_lf_705.dnui_16110100705.model;

import java.util.List;


import cn.dnui_lf_705.dnui_16110100705.bean.CarBean;
import cn.dnui_lf_705.dnui_16110100705.bean.CollectStatus;
import cn.dnui_lf_705.dnui_16110100705.bean.CommentBean;
import cn.dnui_lf_705.dnui_16110100705.bean.FoodInfo;
import cn.dnui_lf_705.dnui_16110100705.bean.ResultBean;
import cn.dnui_lf_705.dnui_16110100705.iface.FoodIface;
import cn.dnui_lf_705.dnui_16110100705.listener.OnRetrofitListener;
import cn.dnui_lf_705.dnui_16110100705.service.CollectService;
import cn.dnui_lf_705.dnui_16110100705.service.FoodService;
import retrofit2.Call;

public class FoodModel extends BaseModel implements FoodIface {
    private FoodService foodService;
    private CollectService collectService;
    public FoodModel(){
        this.foodService=retrofit.create(FoodService.class);
        this.collectService=retrofit.create(CollectService.class);
    }
    @Override
    public void getFoodByShop(String shop_id, OnRetrofitListener listener) {
        Call<List<FoodInfo>> call = foodService.getFoodByShop(shop_id);
        bindCallback(call,listener,1);
    }

    public void getFoodBySearch(String search,OnRetrofitListener listener)
    {
        Call<List<FoodInfo>> call = foodService.getFoodBySearch(search);
        bindCallback(call,listener,3);
    }

    @Override
    public void isCollected(String user_id, String shop_food_id, String flag,OnRetrofitListener listener) {
        Call<CollectStatus> call = collectService.isCollected(user_id,shop_food_id,flag);
        bindCallback(call,listener,2);
    }



    public void userCollectShop(String user_id,String  shop_id, OnRetrofitListener listener){
        Call<ResultBean> call = collectService.userCollectShop(user_id,shop_id);
        bindCallback(call,listener,3);
    }

    public void getFoodById(String food_id,OnRetrofitListener listener){
        Call<FoodInfo> call = foodService.getFoodById(food_id);
        bindCallback(call,listener,4);
    }
    public void getAllCommentsByFood(String food_id,OnRetrofitListener listener){
        Call<List<CommentBean>> call = foodService.getAllCommentsByFood(food_id);
        bindCallback(call,listener,5);
    }
    public void getMyCartByUser(int item_id,OnRetrofitListener listener)
    {
        Call<List<CarBean>> call = foodService.getMyCartByUser(item_id);
        bindCallback(call,listener,6);
    }
    public void deleteCartItem(int item_id,OnRetrofitListener listener)
    {
        Call<ResultBean> call = foodService.deleteCartItem(item_id);
        bindCallback(call,listener,7);
    }

}
